package com.cn.lycss.servlet;

import com.cn.lycss.model.CompanyModel;
import com.cn.lycss.model.NavModel;
import com.cn.lycss.model.NewsModel;
import com.cn.lycss.service.CompanyService;
import com.cn.lycss.service.NavService;
import com.cn.lycss.service.NewsService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/news")
public class NewsServlet extends HomeServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {


//            CompanyService companyService=new CompanyService();
//            CompanyModel companyMode =companyService.getCompanyModel();
//            req.getSession().setAttribute("companyModel",companyMode);
//
//
//            NavService navService=new NavService();
//            NavModel[] navModels=navService.getNavModel();
//
//            req.setAttribute("navModels",navModels);

         CommonServlet.setCompanyAndNavDate(req);
        NewsService newsService=new NewsService();
        NewsModel[] newsModels=newsService.getNewsModelForHomePage();
        req.setAttribute("newsModels",newsModels);
        NewsModel[] newsModels2=newsService.getNewsModelForNewsPage();
        req.setAttribute("newsModels",newsModels2);



            req.getRequestDispatcher("/jsp/news.jsp").forward(req,resp);
        }
    }
